Use radians to get results that are at least vaguely believable...
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 15 Apr 2006 19:54:53 +0000 (19:54 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 15 Apr 2006 19:54:53 +0000 (19:54 +0000)
gpsbabel/route.c

index b13a05da14e913c0a6c5f3f14d72557ecd2396c6..65cae126465bbf7ac54aa4db085af3be6dc5436d 100644 (file)
@@ -456,12 +456,18 @@ void track_recompute(route_head *trk)
 
        QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) {
                this = (waypoint *)elem;
-               this->course = heading(prev->latitude, prev->longitude,
-                       this->latitude, this->longitude);
-               this->speed = radtometers(gcdist(
-                       RAD(prev->latitude), RAD(prev->longitude),
-                       RAD(this->latitude), RAD(this->longitude))) /
+               double tlat, tlon, plat, plon, dist;
+               /* gcdist and headin want radians, not degrees */
+               tlat = RAD(this->latitude);
+               tlon = RAD(this->longitude);
+               plat = RAD(prev->latitude);
+               plon = RAD(prev->longitude);
+               this->course = DEG(heading(plat, plon,
+                       tlat, tlon));
+               dist = radtometers(gcdist(plat, plon, tlat, tlon));
+               this->speed = dist / 
                        labs(this->creation_time - prev->creation_time);
+
                prev = this;
        }
 }